#pragma once
#include "HashTable.h"

namespace Unordered_Map
{
    template<class K,class V>
    class unordered_map
    {
        struct MapKeyValueOf
        {
            const K& operator()(const pair<const K,V>& data)
            {
                return data.first;
            }
        };
        typedef Opened_Hashing::HashTable<K,pair<const K,V>,MapKeyValueOf> HashTable;
    public:
        typedef typename Opened_Hashing::HashTable<K,pair<const K,V>,MapKeyValueOf>::iterator iterator;
        typedef typename Opened_Hashing::HashTable<K,pair<const K,V>,MapKeyValueOf>::const_iterator const_iterator;

        pair<iterator,bool> insert(const pair<K,V>& data)
        {
            return _m.insert(data);
        }
        V& operator[](const K& data)
        {
            pair<iterator,bool> ret = insert(make_pair(data,K()));
            return ret.first->second;
        }
        iterator begin()
        {
            return _m.begin();
        }
        iterator end()
        {
            return _m.end();
        }
        const_iterator begin()const
        {
            return _m.begin();
        }
        const_iterator end()const
        {
            return _m.end();
        }
    private:
        HashTable _m;
    };
};